﻿using System.Collections.Generic;

namespace InternetSpiderLib.Scenes.Filters
{
    /// <summary>
    /// 字符串内容包含过滤器
    /// </summary>
    public class StringContainsSceneFilter : ISceneFilter
    {
        public string Key { get; set; }

        public string Value { get; set; }

        public bool Filter(DataBox data)
        {
            if (string.IsNullOrEmpty(Key) || string.IsNullOrEmpty(Value))
                return false;

            var value = data.Get<string>(Key);
            if (string.IsNullOrEmpty(value))
                return false;

            return value.Contains(Value);
        }
    }
}
